/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.base.entity.Customer;
import com.chlitina.store.modules.cash.entity.StoreConsume;
import com.chlitina.store.modules.employee.entity.Employee;
import com.chlitina.store.modules.sys.entity.Store;
import com.google.common.collect.Lists;

/**
 * 客户诊断Entity
 * @author liujiang
 * @version 2013-06-05
 */
@Entity
@Table(name = "store_customer_exam")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class CustomerExam extends BaseEntity {
	
	private static final long serialVersionUID = 1L;
	private Long id; 				// 诊断编号
	private Store store; 	// 店面
	private Customer customer; 			// 客户姓名
	private Employee employee;				//诊断员工
	private Date exam_time;			// 就诊日期
	private String photo1;			//照片1
	private String photo2;			//照片2
	private String photo3;			//照片3
	private Date show_time;   //专家诊断完成，出结果的时间
	private StoreConsume storeConsume; //是否已买单，消费单号
	
	private List<CustomerExamParameters> examParametersList = Lists.newArrayList();
	private List<CustomerSolution> customerSolutionList = Lists.newArrayList();
	
	public CustomerExam() {
	}

	public CustomerExam(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="STORE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}
	
    @ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="CUSTOMER_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	
    public Date getExam_time() {
		return exam_time;
	}

	public void setExam_time(Date exam_time) {
		this.exam_time = exam_time;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="EMPLOYEE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public String getPhoto1() {
		return photo1;
	}

	public void setPhoto1(String photo1) {
		this.photo1 = photo1;
	}

	public String getPhoto2() {
		return photo2;
	}

	public void setPhoto2(String photo2) {
		this.photo2 = photo2;
	}

	public String getPhoto3() {
		return photo3;
	}

	public void setPhoto3(String photo3) {
		this.photo3 = photo3;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="CONSUME_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public StoreConsume getStoreConsume() {
		return storeConsume;
	}

	public void setStoreConsume(StoreConsume storeConsume) {
		this.storeConsume = storeConsume;
	}

	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY,mappedBy="customerExam")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<CustomerExamParameters> getExamParametersList() {
		return examParametersList;
	}

	public void setExamParametersList(List<CustomerExamParameters> productList) {
		this.examParametersList = productList;
	}
	
	@OneToMany(cascade={CascadeType.REFRESH, CascadeType.MERGE}, fetch=FetchType.LAZY,mappedBy="customerExam")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<CustomerSolution> getCustomerSolutionList() {
		return customerSolutionList;
	}

	public void setCustomerSolutionList(List<CustomerSolution> customerSolutionList) {
		this.customerSolutionList = customerSolutionList;
	}

	public Date getShow_time() {
		return show_time;
	}

	public void setShow_time(Date show_time) {
		this.show_time = show_time;
	}
}